home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 001-025 / scopedisk8 / qint / test.c < prev   
C/C++ Source or Header  |  1995-03-18  |  2KB  |  76 lines

  1.  
  2. /*
  3.  *  QINT TEST ROUTINE
  4.  *
  5.  *  1> test
  6.  *        Ctl D   -quit
  7.  *        Ctl E   -cause test interrupt #1
  8.  *        Ctl F   -cause test interrupt #0
  9.  *
  10.  *        (see printf's to understand what it is printing)
  11.  *
  12.  *    Basic idea: Cycle through various priorities.  The Q interrupts
  13.  *    are both set for priority 16, and thus only work when the counter
  14.  *    is 0...15
  15.  *
  16.  *    If you set one of the Q interrupts to, say, 17, you would then
  17.  *    have to worry about the level 17 Q interrupt interrupting the
  18.  *    level 16 interrupt, and thus surround the level 16 interrupt
  19.  *    with:
  20.  *        char oldpri = SetQPri(127);
  21.  *        puts("blah");
  22.  *        SetQPri(oldpri);
  23.  *
  24.  *    As it is, with both at level 16, they cannot interrupt each other
  25.  *    (if one occurs while the other is running, it is queued till the
  26.  *     other one finishes).
  27.  */
  28.  
  29. #include <exec/types.h>
  30. #include <exec/tasks.h>
  31.  
  32. typedef struct Task TASK;
  33.  
  34. extern TASK *FindTask();
  35.  
  36. int X;
  37. int Enable_Abort;
  38.  
  39. void
  40. myhan(sig)
  41. {
  42.     ++X;
  43.     printf("test# %ld\n", sig);
  44. }
  45.  
  46. main()
  47. {
  48.     short i;
  49.     int j;
  50.  
  51.     Enable_Abort = 0;
  52.  
  53.     printf("tcexcept: %08lx\n", FindTask(NULL)->tc_ExceptCode);
  54.     SetQVector(SIGBREAKB_CTRL_F, myhan, 0, 16);
  55.     SetQVector(SIGBREAKB_CTRL_E, myhan, 1, 16);
  56.     printf("tcexcept: %08lx\n", FindTask(NULL)->tc_ExceptCode);
  57.     printf("tcexmask: %08lx\n", FindTask(NULL)->tc_SigExcept);
  58.     for (i = 0; ; ++i) {
  59.     i &= 31;
  60.     SetQPri(127);
  61.     printf("i = %2ld rcvd: %08lx  excp: %08lx  cnt: %6ld\n", i,
  62.         FindTask(NULL)->tc_SigRecvd, FindTask(NULL)->tc_SigExcept,
  63.         X
  64.     );
  65.     SetQPri(i);
  66.     for (j = 0; j < 100; ++j);
  67.     if (SetSignal(0,SIGBREAKF_CTRL_D) & SIGBREAKF_CTRL_D)
  68.         break;
  69.     }
  70.     SetQVector(SIGBREAKB_CTRL_E, NULL, 0, 0);
  71.     SetQVector(SIGBREAKB_CTRL_F, NULL, 0, 0);
  72.     puts("exiting");
  73.     printf("tcexcept: %08lx\n", FindTask(NULL)->tc_ExceptCode);
  74. }
  75.  
  76.